package cn.woniu.ecommerceplatform.controller;

import cn.woniu.ecommerceplatform.entity.Users;
import cn.woniu.ecommerceplatform.service.UserService;
import cn.woniu.ecommerceplatform.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired(required = false)
    private UserService userService;

    @RequestMapping("queryAllUserByName")
    public ResponseResult<?> queryAllUserByName(String userName){
        return userService.queryAllUserByName(userName);
    }


    @RequestMapping("deleteUserById")
    public ResponseResult<?> deleteUserById(Integer id){
        return userService.deleteUserById(id);
    }

    @PostMapping("updateUserAuth")
    public ResponseResult<?> updateUserAuth(@RequestBody Users users){
        return userService.updateUserAuth(users);
    }

    @RequestMapping("queryAllJob")
    public ResponseResult<?> queryAllJob(){
        return userService.queryAllJob();
    }

    @PostMapping("addUsers")
    public ResponseResult<?> addUsers(@RequestBody Users users){
        return userService.addUsers(users);
    }

    @RequestMapping("queryJobIdByAccount")
    public ResponseResult<?> queryJobIdByAccount(String account){
        return userService.queryJobIdByAccount(account);
    }

    @RequestMapping("queryUserByAccountMy")
    public ResponseResult<?> queryUserByAccountMy(String account){
        return userService.queryUserByAccountMy(account);
    }


    @PostMapping("updateUserByAccountMy")
    public ResponseResult<?> updateUserByAccountMy(@RequestBody Users users){
        return userService.updateUserByAccountMy(users);
    }
    @RequestMapping("selectIdByAccount")
    public ResponseResult<?> selectIdByAccount(String account){
        return userService.selectIdByAccount(account);
    }
}
